package com.mo.web.config;


import com.mo.service.realm.ShiroRealm;
import org.apache.shiro.realm.Realm;
import org.apache.shiro.spring.web.config.DefaultShiroFilterChainDefinition;
import org.apache.shiro.spring.web.config.ShiroFilterChainDefinition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ShiroConfig {


    @Bean
    public Realm realm() {
        return new ShiroRealm();
    }



    @Bean
    public ShiroFilterChainDefinition shiroFilterChainDefinition() {

        DefaultShiroFilterChainDefinition chainDefinition =
                new DefaultShiroFilterChainDefinition();

        chainDefinition.addPathDefinition("/user/login/**","anon");

        chainDefinition.addPathDefinition("/user/logout","logout");

        chainDefinition.addPathDefinition("/**", "user");

        return chainDefinition;
    }


}
